#pragma once
#include "agentstate.h"
#include "stdafx.h"


class FollowTrackState :
	public AgentState
{
private:
	bool getDirtyPath(Vector2 start);
	bool getMissedPoint(Vector2 start);
	Vector2 pfFieldPath(tank_t* tank);
	void setNextWayPoint(tank_t* tank);

	int pos;
	int trackPos;
	bool _complete;
	float cutoff;
	
	bool recalc;

	std::vector<Vector2> path;
	std::vector<Vector2> currentTrack;

	Graph* g;
	World* w;
	BZRC* com;
	node* goal;

	Vector2 lastPos;

	int cycles;
	bool backup;
	bool reverseLeft;
	bool cleanup;
	bool isdone;
	bool vert;
	int stuck;

	int cleanupCount;

public:
	FollowTrackState(Graph* g, tank_t* tank, std::vector<Vector2> track, bool vertical=false);
	~FollowTrackState(void);

	Command GetCommand(GridAgent* agent);
	bool done();
	bool complete();
};

